#ifndef DEVICEMANAGEMENT_H
#define DEVICEMANAGEMENT_H

#include <QWidget>
#include <QTableWidget>
#include <QTreeWidget>
#include <QDate>
#include <QTimer>
#include <QMutex>
#include "databasemanager.h"

namespace Ui {
class DeviceManagement;
}

class DeviceDialog;

class DeviceManagement : public QWidget
{
    Q_OBJECT

public:
    mutable QMutex  m_mutex;
    explicit DeviceManagement(QWidget *parent = nullptr);
    ~DeviceManagement();

private slots:
    void onAddDevice();
    void onEditDevice();
    void onDeleteDevice();
    void onSearchDevice();
    void onGroupFilterChanged(int index);
    void onCreateGroup();
    void showContextMenu(const QPoint &pos);

private:
    Ui::DeviceManagement *ui;
    DatabaseManager* dbManager;  // 数据库管理器指针

    void setupTable();
    void setupConnections();
public:
    void refreshDeviceList();
    void refreshGroupList();
    void setDatabaseManager(DatabaseManager* manager);
};

#endif // DEVICEMANAGEMENT_H
